﻿using System;
using System.Collections.Generic;

namespace SiteUnity.Frame.Common.Tools.Class
{
    public class ClassCollection
    {
        static public T Find<T>(List<T> collection, string property, object value)
        { 
            foreach (T item in collection)
            {
                if (ClassTools.GetProperty(item, property).Equals(value))
                    return item;
            }
            return Activator.CreateInstance<T>();
        }

        static public List<T> FindAll<T>(List<T> collection, string property, object value)
        {
            List<T> result = new List<T>();
            foreach (T item in collection)
            {
                if (ClassTools.GetProperty(item, property).Equals(value))
                    result.Add(item);
            }
            return result;
        }
    }
}
